<template>
  <div class="pagination-container">
    <el-pagination
      :background="background"
      :total="total"
      :layout="layout"
      :hide-on-single-page="true"
      @prev-click="handlePrevClick"
      @next-click="handleNextClick"
      @current-change="handleCurrentChange"
    ></el-pagination>
  </div>
</template>

<script>
  export default {
    props: {
      // 总条数
      total: {
        type: Number,
        default: 0,
      },
      // 是否开启按钮背景色
      background: {
        type: Boolean,
        default: false,
      },
      // 按钮选择
      layout: {
        type: String,
        default: 'prev, pager, next, jumper, ->, total',
      },
    },
    methods: {
      handlePrevClick(pager) {
        this.$emit('prev-click', pager)
      },
      handleNextClick(pager) {
        this.$emit('next-click', pager)
      },
      handleCurrentChange(pager) {
        this.$emit('current-change', pager)
      },
    },
  }
</script>

<style>
  .pagination-container {
    margin-top: 20px;
  }
</style>
